list_a =[
    [1,2,3,4],
    [5,6,7,8],
    [9,10,11,12],
    [13,14,15,16],
]
a=0
b=0
list_i = []
while b != 4 :
    b += 1
    for i in range(a,b):
        list_i.append(i)
    while b == 4 and a !=3:
        a+=1
        for i in range(a,b):
            list_i.append(i)
c=4
d=4
list_j = []
while c != 0 :
    c -= 1
    for j in range(c,d):
        list_j.append(j)
    while c == 0 and d !=1:
        d-=1
        for j in range(c,d):
            list_j.append(j)
for i in range(16):
    print(list_a[list_i[i]][list_j[i]],end=" ")
